<!--// 搜索框所在的导航头-->
<template>
  <div>
    <el-row style="margin-top: 10px">
      <el-col :span="2">
        <div class="grid-content bg-purple-light">
          <!-- <img
            id="logo"
            src="../../assets/logo.png"
            height="35"
            style="margin-left: 30px"
            @click="toHome"
          /> -->
          <el-link
            target="_blank"
            @click="toHome"
            style="
              color: white;
              font-size: large;
              margin-top: 5px;
              font-weight: bold;
            "
          >
            < 回到主页
          </el-link>
        </div>
      </el-col>
      <el-col :span="12">
        <div class="grid-content bg-purple-light">
          <el-input placeholder="请输入内容" v-model="input" clearable>
          </el-input>
          <el-button
            icon="el-icon-search"
            @click="toSearch"
            plain
            style="margin-left: 5px"
            >搜索
          </el-button>
        </div>
      </el-col>
      <el-col :span="8" style="">
        <div class="grid-content bg-purple">
          <el-button-group>
            <el-button
              plain
              icon="el-icon-shopping-cart-2"
              @click="toUserCart()"
              >购物车
            </el-button>
            <el-button
              icon="el-icon-shopping-bag-2"
              @click="toUserOrder()"
              plain
              style="margin-left: 10px"
              >我的订单
            </el-button>
          </el-button-group>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  name: "HeaderNav",
  data() {
    return {
      input: "",
    };
  },
  methods: {
    toHome() {
      this.$router.push({
        path: "/",
      });
    },
    //去用户购物车页面
    toUserCart() {
      console.log(this.$router);
      this.$router.push({
        path: "/user-about/cart",
      });
      location.reload();
    },
    toUserOrder() {
      this.$router.push({
        path: "/user-about/order",
      });
      location.reload();
    },

    //搜索
    toSearch() {
      this.$router.push({
        name: "search",
        params: {
          keyword: this.input,
        },
        path: "/search",
        query: {
          keyword: this.input,
        },
      });
      location.reload();
    },
  },
};
</script>

<style lang="scss" scoped>
.el-input {
  width: 350px;
}

#logo:hover {
  border: 3px solid red;
}
</style>
